package com.trainoo.alibaba.nacos;

import com.trainoo.alibaba.nacos.api.IHelloWorldService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zt
 * @Date: 2019/12/13 16:15
 * @Description:
 */
@EnableDiscoveryClient
@SpringBootApplication
public class DubboClientApplication {

    /**
     *  经过测试发现，nacos 控制台上对dubbo服务做上下线，并不会影响到服务的调用
     */
    public static void main(String[] args) {
        SpringApplication.run(DubboClientApplication.class);
    }

    @RestController
    static class TestController{
        @Reference
        private IHelloWorldService helloWorldService;

        @GetMapping("/test")
        public String testDubbo(@RequestParam String name){
            return helloWorldService.hello(name);
        }
    }
}
